package com.xinlong.entity;

import java.util.List;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.xinlong.utils.DateandString;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;

import java.text.ParseException;
import java.util.Date;

public class product {
     private String id; // 主键
     private String productNum; // 编号 唯一
     private String productName; // 名称
     private String cityName; // 出发城市
     private Date endTime;
     private List<Route> route;

    public List<Route> getRoute() {
        return route;
    }

    public void setRoute(List<Route> route) {
        this.route = route;
    }

    private Date departureTime; // 出发时间
     private String departureTimeStr;
     private String endTimeStr;
     private double productPrice; // 产品价格
     private String productDesc; // 产品描述
     private Integer productStatus; // 状态 1 未进行 2 进行中 3 已完成
     private String productStatusStr;
     private Integer vehicleid;  //车辆管理
     private Vehicle vehicle;


    public Vehicle getVehicle() {
        return vehicle;
    }

    public void setVehicle(Vehicle vehicle) {
        this.vehicle = vehicle;
    }

    @Override
    public String toString() {
        ObjectMapper mapper = new ObjectMapper();
        String json = "";
        try {
            json = mapper.writeValueAsString(this);
        }catch (Exception e){
            e.printStackTrace();
        }
        return json;
        /*return "{" +
                "\"cityName\":"+"\""+cityName+"\""+
                ",\"id\":"+id+
                ",\"departureTimeStr\":"+"\""+getDepartureTimeStr()+"\""+
                ",\"productDesc\":"+"\""+productDesc+"\""+
                ",\"routes\":"+"\"["+route+"\"]"+
                '}';*/
    }


    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public String getEndTimeStr() {
        if(endTime!=null){
            endTimeStr=DateandString.Date2String(endTime,"yyyy-MM-dd hh:mm");
        }

        return endTimeStr;
    }



    public void setEndTimeStr(String endTimeStr) throws ParseException {
        endTime=DateandString.String2Date(endTimeStr,"yyyy-MM-dd hh:mm");
        this.endTimeStr = endTimeStr;
    }

    public Integer getVehicleid() {
        return vehicleid;
    }

    public void setVehicleid(Integer vehicleid) {
        this.vehicleid = vehicleid;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getProductNum() {
        return productNum;
    }

    public void setProductNum(String productNum) {
        this.productNum = productNum;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public Date getDepartureTime() {
        return departureTime;
    }

    public void setDepartureTime(Date departureTime) {
        this.departureTime = departureTime;
    }

    public String getDepartureTimeStr() {
        if(departureTime!=null){
            departureTimeStr= DateandString.Date2String(departureTime,"yyyy-MM-dd hh:mm");
        }
        return departureTimeStr;
    }

    public void setDepartureTimeStr(String departureTimeStr) throws ParseException {
        departureTime=DateandString.String2Date(departureTimeStr,"yyyy-MM-dd hh:mm");
        this.departureTimeStr = departureTimeStr;
    }

    public double getProductPrice() {
        return productPrice;
    }

    public void setProductPrice(double productPrice) {
        this.productPrice = productPrice;
    }

    public String getProductDesc() {
        return productDesc;
    }

    public void setProductDesc(String productDesc) {
        this.productDesc = productDesc;
    }

    public Integer getProductStatus() {
        return productStatus;
    }

    public void setProductStatus(Integer productStatus) {
        this.productStatus = productStatus;
    }

    public String getProductStatusStr() {
        if(productStatus!=null){
            // 状态 1 未进行 2 进行中 3 已完成
            if (productStatus==1){
                productStatusStr="未进行";
            }
            if (productStatus==2){
                productStatusStr="进行中";
            }
            if (productStatus==3){
                productStatusStr="已完成";
            }
        }
        return productStatusStr;
    }

    public void setProductStatusStr(String productStatusStr) {
        this.productStatusStr = productStatusStr;
    }
}
